/**
 * @summary 文章请求模块
 */

import req from '@/utils/request';
import * as URL from '@/constants/api';

/**
 * @param { string } id
 * @returns
 * @summary 获取文章列表
 */
export function getArticleList(id) {
  return req({
    url: URL.ARTICLE,
    params: {
      channel_id: id,
      timestamp: Date.now(),
    },
  })
    .then((res) => res.data.data.results)
    .catch(() => []);
}

/**
 * @param { string } id
 * @returns
 * @summary 获取文章详情
 */
export function getArticleDetail(id) {
  return req({
    url: `${ URL.ARTICLE }/${ id }`,
  })
    .then((res) => res.data.data) // to do
    .catch(() => []);
}
